
layui.config({
    base: '/static/js/layuiModulesEX/'
});
layui.use(['paging','form'], function() {
    var $ = layui.jquery,
        paging = layui.paging(),
        layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
        layer = layui.layer, //获取当前窗口的layer对象
        form = layui.form();

    // var map = new BMap.Map("bdMap"); //创建地图实例

    paging.init({
        openWait: true,
        url:'/orginfo/findByCondition',
        elem: '#content', //内容容器
        params: { //发送到服务端的参数
            isTemporary:1
        },
        contentType : "application/json; charset=utf-8",
        type: 'POST',
        tempElem: '#tpl', //模块容器
        pageConfig: { //分页参数配置
            elem: 'paged', //分页容器
            pageSize: 10 //分页大小
        },
        success: function() { //渲染成功的回调
            //alert('渲染成功');
        },
        fail: function(msg) { //获取数据失败的回调
            //alert('获取数据失败')
        },
        complate: function() { //完成的回调
            //alert('处理完成');

            //绑定所有编辑按钮事件
            $('#content').children('tr').each(function() {
                //获取每行记录的id值
                var $that = $(this).children('td:last-child');
                var id = $that.children('a[data-opt=more]').data('id');
                console.log(id);
                $that.children('a[data-opt=more]').on('click', function() {
                    vm.jumpToOrgInfo(id,2);
                });
            });

        }
    });
    var vm = new Vue({
        el:'#Vue',
        data:{
            show:true,
            orginfo:{
                publisherid:publisherid
            }
        },
        methods:{
            pass:function () {
                axios.get('/orginfo/modifyState/'+ vm.orginfo.id + '/' + 3)
                    .then(function (res) {
                        layer.msg("操作成功",{time:1500},function () {
                            vm.reload();
                        })
                    })
                    .catch(function (res) {
                        layer.msg("程序出错");
                    });
            },
            refuse:function () {
                axios.get('/orginfo/modifyState/'+ vm.orginfo.id + '/' + 4)
                    .then(function (res) {
                        layer.msg("操作成功",{time:1500},function () {
                            vm.reload();
                        })
                    })
                    .catch(function (res) {
                        layer.msg("程序出错");
                    });
            },
            /**
             * 跳转至orgInfo页面
             */
            jumpToOrgInfo:function (orgId,operateType) {
                location.href = "/student/orgInfo?orgId=" + orgId + "&operateType=" + operateType + "&origin='/admin/orgList'";
            },
            /**
             * 筛选按钮
             */
            selectState:function () {
                var state = $('#state').val();
                console.log(state);
                paging.get({state:state});
            },
            /**
             * 重置按钮
             */
            reset:function () {
                // $('select[name=state]').next().find('[lay-value=""]').click();
                form.render("select");
                paging.get({state:""});
            },
            /**
             * 添加用人单位按钮
             */
            add:function () {
                vm.jumpToOrgInfo(null,1);
            }
        }
    });

    form.render();
});